<?php
class File{
	
	function uploadfile($filename,$loacation){
		$ftype = getSuffix($_FILES[$filename]["name"]);
		$attachid = uuid2();
		$fname = $attachid.$ftype;
		$datestr = date('Y-m-d');
		if(!file_exists(DR.'/'.$loacation.'/'.$datestr)){
			mkdir(DR.'/'.$loacation.'/'.$datestr);
		}
		$floc = DR.'/'.$loacation.'/'.$datestr.'/'.$fname;
		move_uploaded_file( $_FILES[$filename]['tmp_name'],$floc);
		return $loacation.'/'.$datestr.'/'.$fname;
	}
	
	function unlink($location){
		$droot = dirname(__FILE__);
		$file = $droot.'../../../'.$location;
		if(file_exists($location)){
			unlink($file);
		}
	}
	
	
}